<?php

/**
 * This is the model class for table "{{transaksi_atribut}}".
 *
 * The followings are the available columns in table '{{transaksi_atribut}}':
 * @property integer $id
 * @property integer $id_transaksi
 * @property string $nota_divmum_no
 * @property string $nota_divmum_tangggal
 * @property string $spk_no
 * @property string $spk_tangggal
 * @property string $po_no
 * @property string $po_tanggal
 *
 * The followings are the available model relations:
 * @property Transaksi $idTransaksi
 */
class TransaksiAtribut extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return TransaksiAtribut the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{transaksi_atribut}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('id_transaksi', 'required'),
			array('id_transaksi', 'numerical', 'integerOnly'=>true),
			array('nota_divmum_tangggal, spk_tangggal, po_tanggal', 'date', 'format'=>'yyyy-MM-dd'),
			array('nota_divmum_no, spk_no', 'length', 'max'=>25),
			array('po_no', 'length', 'max'=>20),
			array('nota_divmum_tangggal, spk_tangggal, po_tanggal', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, id_transaksi, nota_divmum_no, nota_divmum_tangggal, spk_no, spk_tangggal, po_no, po_tanggal', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'idTransaksi' => array(self::BELONGS_TO, 'Transaksi', 'id_transaksi'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'id_transaksi' => 'Id Transaksi',
			'nota_divmum_no' => ' No Nota Divmum',
			'nota_divmum_tangggal' => 'Tangggal Nota Divmum',
			'spk_no' => 'No Spk',
			'spk_tangggal' => 'Tangggal Spk',
			'po_no' => 'No PO',
			'po_tanggal' => 'Tanggal PO',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('id_transaksi',$this->id_transaksi);
		$criteria->compare('nota_divmum_no',$this->nota_divmum_no,true);
		$criteria->compare('nota_divmum_tangggal',$this->nota_divmum_tangggal,true);
		$criteria->compare('spk_no',$this->spk_no,true);
		$criteria->compare('spk_tangggal',$this->spk_tangggal,true);
		$criteria->compare('po_no',$this->po_no,true);
		$criteria->compare('po_tanggal',$this->po_tanggal,true);

		return new CActiveDataProvider(get_class($this), array(
			'criteria'=>$criteria,
		));
	}
}